package com.junmeng.jdemo.matrix;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Matrix;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.junmeng.jdemo.R;
import com.junmeng.jdemo.databinding.ActivityMatrixBinding;

import java.util.Collection;
import java.util.Collections;
import java.util.List;

public class MatrixActivity extends AppCompatActivity {

    private static final String TAG = "MatrixActivity";
    ActivityMatrixBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityMatrixBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        Matrix matrix= binding.image.getImageMatrix();
        Log.i(TAG,"imageMatrix="+matrix.toString());
         matrix= binding.image.getMatrix();
        Log.i(TAG,"matrix="+matrix.toString());


    }

    public void onClickScale(View view) {

//        Matrix matrix= binding.image.getMatrix();
        Matrix matrix=new Matrix();
        matrix.postScale(2,1);
        Log.i(TAG,"matrix="+matrix.toString());
        binding.image.setImageMatrix(matrix);
        Log.i(TAG,"matrix="+binding.image.getImageMatrix().toString());
    }

    public void onClickTestPost(View view) {

        //post即是右乘
//        Matrix matrix= binding.image.getMatrix();
        Matrix matrix=new Matrix();

        matrix.postRotate((float) (Math.PI/2));
        matrix.postSkew(1,2);
        Log.i(TAG,"matrix="+matrix.toString());
        binding.image.setImageMatrix(matrix);
        Log.i(TAG,"matrix="+binding.image.getImageMatrix().toString());
    }

    public void onClickTestPre(View view) {

//        Matrix matrix= binding.image.getMatrix();
        Matrix matrix=new Matrix();
        matrix.preSkew(1,2);
        matrix.preRotate((float) (Math.PI/2));
        Log.i(TAG,"matrix="+matrix.toString());
        binding.image.setImageMatrix(matrix);
        Log.i(TAG,"matrix="+binding.image.getImageMatrix().toString());

    }

}